package com.mx.beautiful.biz;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;

import android.content.Context;

import com.mx.beautiful.constants.Urls;
import com.mx.beautiful.utils.FileUtil;
import com.mx.beautiful.utils.IntentUtil;

public class BigShowListBiz {
	private final String RegexContent = "<DIV\\sid=eData[^>]{0,25}>[\\s\\S]*?(?=<Link)";
	private final String RegexImageUrl = "(?<=>)/[^<]*(?=<)";

	public List<String> getBigShowList(String Url, Context context) {
		String htmlCode = IntentUtil.doGet(Url, context);
		if (htmlCode == null)
			return null;
		String content = null;
		List<String> list = new ArrayList<String>();
		/*
		 * content
		 */
		Matcher matcherContent = FileUtil.getPattern(RegexContent, htmlCode);
		if (!matcherContent.find())
			return null;
		content = matcherContent.group();
		/*
		 * list
		 */
		Matcher matcherImageList = FileUtil.getPattern(RegexImageUrl, content);
		while (matcherImageList.find()) {
			if (!list.contains(Urls.PageUrlMain + matcherImageList.group())&&matcherImageList.group().lastIndexOf("-lp")==-1) {
				list.add(Urls.PageUrlMain + matcherImageList.group());
			}
		}
		return list;
	}
}
